/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.liwalo.model;

/**
 *
 * @author Carlos
 */
public enum Roles {
    ADMIN("1", "ADMIN"){
        @Override
        public String toString(){
            return "1";
        }
    },
    CUSTOMER("2", "CUSTOMER"){
        @Override
        public String toString(){
            return "2";
        }
    },
    STORE("3", "STORE"){
        @Override
        public String toString(){
            return "3";
        }
    },
    GUEST("4", "GUEST"){
        @Override
        public String toString(){
            return "4";
        }
    };
    
    String valorEnum;
    String nombreEnum;

    private Roles(String valorEnum, String nombreEnum) {
        this.valorEnum = valorEnum;
        this.nombreEnum = nombreEnum;
    }

    public String getNombreEnum() {
        return nombreEnum;
    }

    public String getValorEnum() {
        return valorEnum;
    }

    public void setNombreEnum(String nombreEnum) {
        this.nombreEnum = nombreEnum;
    }

    public void setValorEnum(String valorEnum) {
        this.valorEnum = valorEnum;
    }
    
    public static Roles convertir(String valorEnum){
        if(valorEnum == null)
            return null;
        if("1".equalsIgnoreCase(valorEnum)){
            return ADMIN;
        }else if ("2".equalsIgnoreCase(valorEnum)){
            return CUSTOMER;
        }else if ("3".equalsIgnoreCase(valorEnum)){
            return STORE;
        }else if ("4".equalsIgnoreCase(valorEnum)){
            return GUEST;
        }else{
            return null;
        }
    } 
}
